
import { getTableHeight, changePagination, selectChange } from "@/utils/table";
import { edit, changeStatus, add } from "@/utils/form";

import { upStatus } from "@/api/user";

// 表格组件 传参
export default {
  data() {
    return {

      dataGrid: {
        changePagination: (pagination) => changePagination("dataGrid", this, pagination, this.searchForm.refresh),
        selectChange: (multipleSelection) => selectChange("dataGrid", this, multipleSelection, this.searchForm.refresh),
        height: getTableHeight("", "dataGrid", this, 340),
        visible: false,
        loading: false,
        columns: [
          {
            width: "180",
            label: "操作",
            action: true,
            fixed: "left",
            align: "center"
          },
          {
            label: "工号",
            prop: "username",
            width: 100,
            align: "center"
          },
          {
            label: "姓名",
            prop: "name",
            align: "center",
            width: 100
          },
          {
            label: "部门/组织",
            prop: "deptGroup",
            align: "center",
            width: 100
          },
          {
            label: "职务描述",
            prop: "job",
            align: "center",
            width: 100
          },
          {
            label: "性别",
            prop: "sex",
            align: "center",
            width: 100
          },
          {
            label: "状态",
            prop: "statusName",
            align: "center",
            width: 100
          },
          {
            label: "备注",
            prop: "remark",
            align: "center"
          }
        ],
        data: [],
        pagination: {
          hidden: 1,
          pageNum: 1,
          pageSizes: [50, 100, 150],
          pageSize: 50,
          total: 0,
          pageCount: 0
        },
        btnList: [
          {
            label: "编辑",
            mthods: (row) => edit("registerForm", this, "", row),
            type: "text",
            hasPermission: "qm:auth:user:do"
          },
          {
            label: "修改密码",
            mthods: (row) => {
              this.passwordForm.options[0].value = row.username;
              add("passwordForm", this, "", row);
            },
            type: "text",
            hasPermission: "qm:auth:user:do"
          },
          {
            label: "启用",
            hide: (row) => row.status === 1 && row.name !== "admin",
            mthods: (row) => changeStatus(row, upStatus, "确定启用?", this.searchForm.refresh(), 0),
            type: "text",
            hasPermission: "qm:auth:user:do"
          },
          {
            label: "禁用",
            hide: (row) => !row.status && row.name !== "admin",
            mthods: (row) => changeStatus(row, upStatus, "确定禁用?", this.searchForm.refresh(), 1),
            type: "text",
            hasPermission: "qm:auth:user:do",
            style: {
              color: "#F56C6C"
            }
          }
        ]
      }
    };
  },
  methods: {

  }

};
